package com.leixin.demo.controller;

import com.leixin.demo.entity.UserEntity;
import com.leixin.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

@RestController
@RequestMapping(value = "index")
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping(value = "user")
    public void addUser(@RequestBody UserEntity userEntity){
        userEntity.setId(UUID.randomUUID().toString());
        userService.addUser(userEntity);
    }
    @GetMapping(value = "get")
    public UserEntity get(String id){
       return userService.queryUserById(id);
    }
}
